package com.cn.crmsystem.controller.approveController;
import com.cn.crmsystem.pojo.*;
import com.cn.crmsystem.service.approveService.MyTaskService;
import io.swagger.annotations.*;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.security.Security;
import java.util.ArrayList;
import java.util.List;

@Controller
@Api(value = "我的任务api",tags = "我的任务API")
public class MyTaskController {
	@Autowired
	MyTaskService myTaskService;
//我的任务条件查询
@RequestMapping(value = "/SelectMyCondition",name = "我的任务条件查询",method = RequestMethod.POST)
@ApiOperation(value = "我的任务条件查询",notes = "条件查询",httpMethod = "post", response = String.class)
@ResponseBody
public ResultJson selectMyCondition(@RequestBody
									@ApiParam(name = "通过或者拒绝",value = "状态更新",required = false) Task task){
	//Login login = (Login) SecurityUtils.getSubject().getPrincipal();
	Login login = new Login();
	login.setUser_id(1);
	System.out.println(login);
	ResultJson resultJson=myTaskService.SelectMyConditionAll(task,login);
	return resultJson;
}
//我的任务全查
@RequestMapping(value = "/SelectMyAll",name = "我的任务全查",method = RequestMethod.POST)
@ApiOperation(value = "我的任务全查",notes = "查询",httpMethod = "POST", response = String.class)
@ResponseBody
public ResultJson SelectMyAll(){
	ResultJson resultJson=new ResultJson();
	Login login = new Login();
	login.setUser_id(13);
	Integer userid=login.getUser_id();
	System.out.println(userid);
	resultJson=myTaskService.SelectMyAll(userid);
	return resultJson;
}
//查询参与者
@RequestMapping(value = "/SelectMyJoinner",name = "查询参与者",method = RequestMethod.POST)
@ApiOperation(value = "查询参与者",notes = "查询",httpMethod = "POST", response = String.class)
@ResponseBody
public ResultJson SelectMyJoinner(){
	ResultJson resultJson=new ResultJson();
	Login login = new Login();
	login.setUser_id(1);
	resultJson=myTaskService.SelectJoinner(login);
	return resultJson;
}
//任务修改
@RequestMapping(value = "/UpdateMyTask",name = "任务修改",method = RequestMethod.POST)
@ApiOperation(value = "任务修改",notes = "更新",httpMethod = "POST", response = String.class)
@ResponseBody
public ResultJson UpdateMyTask(@RequestBody
								@ApiParam(name ="新建任务",value = "增加") Task task){
	ResultJson resultJson=new ResultJson();
	resultJson=myTaskService.UpdateMyTask(task);
	return resultJson;
}
//任务删除
@RequestMapping(value = "/DeleteMyTask",name = "任务删除",method = RequestMethod.POST)
@ApiOperation(value = "任务删除",notes = "更改deleteid",httpMethod = "POST", response = String.class)
@ApiImplicitParams({
		@ApiImplicitParam(name = "taskId",value = "任务id",paramType = "query",dataType = "Integer",required = false)
})
@ResponseBody
public ResultJson DeleteMyTask(@RequestParam(name = "taskId") Integer taskId){
	ResultJson resultJson=new ResultJson();
	resultJson=myTaskService.DeleteMyTask(taskId);
	return resultJson;
}
//任务新增
@RequestMapping(value = "/InsertMyTask",name = "任务新增",method = RequestMethod.POST)
@ApiOperation(value = "任务新增",notes = "插入",httpMethod = "POST", response = String.class)
@ResponseBody
public ResultJson InsertMyTask(@RequestBody
								@ApiParam(name ="新建任务",value = "增加") Task task){
	ResultJson resultJson=new ResultJson();
	resultJson=myTaskService.InsertMyTask(task);
	return resultJson;
}
//参与人增加
@RequestMapping(value = "/InsertJoinner",name = "参与人新增",method = RequestMethod.POST)
@ApiOperation(value = "参与人新增",notes = "插入",httpMethod = "POST", response = String.class)
@ResponseBody
public ResultJson InsertJoinner(@RequestBody
							   @ApiParam(name ="参与人新增",value = "参与人新增") Task task){
	ResultJson resultJson=new ResultJson();
	resultJson=myTaskService.JoinnerInsert(task);
	return resultJson;
}
	//参与人删除
	@RequestMapping(value = "/DeleteJoinner",name = "参与人删除",method = RequestMethod.POST)
	@ApiOperation(value = "参与人删除",notes = "参与人删除",httpMethod = "POST", response = String.class)
	@ResponseBody
	public ResultJson DeleteJoinner(@RequestBody
									@ApiParam(name ="参与人删除",value = "参与人删除") Task task){
		ResultJson resultJson=new ResultJson();
		resultJson=myTaskService.JoinnerDelete(task);
		return resultJson;
	}
}
